package org.test.cloud.stream.rocketmq.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

@Configuration
public class PubSubExample {

    private static final Logger log = LoggerFactory.getLogger(PubSubExample.class);

    @Bean
    public Supplier<String> source() {
        return () -> {
            String message = "from example source";
            log.info("==== {} ====", message);
            return message;
        };
    }

    @Bean
    public Function<String, String> transfer() {
        return message -> {
            log.info("==== transfer {} ====", message);
            return "transfer " + message;
        };
    }

    @Bean
    public Consumer<String> sink() {
        return message -> log.info("==== at sink {} ====", message);
    }
}
